﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using coliseu.BussinessLayer;

namespace coliseu.Views.Rotinas_Diarias
{
    public partial class FrmListRotina : Form
    {
        RotinaBL rBL = new RotinaBL();

        public FrmListRotina()
        {
            InitializeComponent();
        }

        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            if (panel1.Visible)
                panel1.Visible = false;
            else
                panel1.Visible = true;
        }

        private void FrmListRotina_Load(object sender, EventArgs e)
        {
            rotinaBindingSource.DataSource = rBL.selecionar(DateTime.Now.Date,DateTime.Now.Date);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            rotinaBindingSource.DataSource = rBL.selecionar(dateTimePicker1.Value.Date, dateTimePicker2.Value.Date);
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            FrmCadRotina c = new FrmCadRotina(rBL);
            c.ShowDialog();
            rotinaBindingSource.DataSource = rBL.selecionar(DateTime.Now.Date, DateTime.Now.Date);
        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            FrmCadRotina c = new FrmCadRotina(((rotina)rotinaBindingSource.Current), rBL);
            c.ShowDialog();
            rotinaBindingSource.DataSource = rBL.selecionar(DateTime.Now.Date, DateTime.Now.Date);
        }

        private void toolStripButton4_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Deseja excluir?", "Confirmação", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
            {
                rBL.excluir((rotina)rotinaBindingSource.Current);
                rotinaBindingSource.DataSource = rBL.selecionar(DateTime.Now.Date, DateTime.Now.Date);
            }
        }
    }
}
